<?php
header("content-type:text/html;charset=utf-8");
set_time_limit(0);
$con = mysqli_connect("localhost","root","root");
$select_db = mysqli_select_db($con, 'wufeng');
if (!$select_db) {
	die("could not connect to the db:\n" .  mysqli_error());
}

// // 获取所有数据
// $sql = "select id,title,description,content from article_copy";
// $res = mysqli_query($con, $sql);
// if (!$res) {
// 	die("could get the res:\n" . mysqli_error());
// }
// while ($row = mysqli_fetch_assoc($res)) {
// 	// // 将content字段处理为description字段
// 	// $preg = "/<script[\s\S]*?<\/script>/i";
// 	// $row['description'] = preg_replace($preg,"",$row['content']); 
// 	// $row['description'] = str_replace('&nbsp;', '', strip_tags($row['description']));
// 	// $row['description'] = preg_replace("/(\r\n|\n|\r|\t)/i", '', $row['description']);
// 	// $row['description'] = addslashes($row['description']);
// 	// $search = array(" ","　","\n","\r","\t");
// 	// $replace = array("","","","","");
// 	// $row['description'] = str_replace($search, $replace, $row['description']);
// 	// $row['description'] = mb_substr($row['description'], 0, 250);
// 	// unset($row['content']);
// 	// $sql1 = "update article_copy set description='" . $row['description'] . "' where id=". $row['id'] . " limit 1";
// 	// echo $sql1 . "\r\n";
// 	// mysqli_query($con, $sql1);
	
// 	// // 处理content
// 	// $preg = "/<script[\s\S]*?<\/script>/i";
// 	// $content = preg_replace($preg,"",$row['content']); 
// 	// $content = strip_tags($content, '<div><p><span><ul><li><ol><dl><dt><dd><strong><b><font>');
// 	// $content = str_replace('<div id="diycontenttop" class="area"></div>', '', $content);
// 	// $content = str_replace('<div id="diycontentbottom" class="area"></div>', '', $content);
// 	// $content = str_replace('<div id="click_div"></div>', '', $content);
// 	// $content = str_replace('<div id="diycontentclickbottom" class="area"></div>', '', $content);
	
// 	// $content = preg_replace("/(\r\n|\n|\r|\t)/i", '', $content);
// 	// $sql1 = "update article_copy set content='" . $content . "' where id=". $row['id'] . " limit 1";
// 	// echo $sql1 . "\r\n\r\n";
//   // mysqli_query($con, $sql1);
  
//   //print_r($row);

// }


// // 获取栏目分组后数据 -- 脚本设置栏目id
// $sql = "SELECT type_name, count(*) sum from article_copy GROUP BY type_name";
// $res = mysqli_query($con, $sql);

// $n = 3;

// while ($row = mysqli_fetch_assoc($res)) {
//   $sqlTypeIdUpdate = "update article_copy set type_id=" . $n . " where type_name='". $row['type_name'] . "'";
//   echo $sqlTypeIdUpdate . "\r\n\r\n";
//   echo "---\r\n";
//   mysqli_query($con, $sqlTypeIdUpdate);

//   $n++;

// }

//关闭数据库连接
mysqli_close($con);

?>